package a_;

import org.junit.Test;

import java.io.*;

public class PrintStream {
    @Test
    public void test1() throws FileNotFoundException, UnsupportedEncodingException {
        PrintWriter pw =new PrintWriter(
                new OutputStreamWriter(new FileOutputStream("printStream.txt", true),"UTF-8"),true);
        pw.write("中");
        pw.print("中");
        //自动刷新缓冲区 - 只有遇到println才执行
        pw.println("中");
    }

    @Test
    public void test01() throws IOException {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(
                        new FileInputStream("printStream.txt")
                )
        );
        String s;
        while ((s = br.readLine()) != null){
            System.out.println(s);
        }

    }
}
